﻿@using QDT.Common
@using QDT.Core
@using QDT.Core.Assignments
@using QDT.Core.Projects
@using QDT.MVC
@using QDT.MVC.UI
@using QDT.Web
@model QDT.Common.IPagedList<QDT.Core.Assignments.Assignment>
@{
    ViewBag.Title = "债权转让";
    int i = 1;
}
@section Head
{
    <script type="text/javascript" src="@Url.Content("~/Content/Default/JS/vendor/raphael.2.1.0.min.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/Content/Default/JS/vendor/justgage.1.0.1.min.js")"></script>
    <link href="/Content/Default/CSS/project_list.css" rel="stylesheet" type="text/css" />
}

<div class="">
    <div>
        @Html.Partial("_ListNav")
        <div class="wrap filter-wrap" style="border-bottom: 1px solid #E5E5E5;">
            <div class="container filter-container" style="width: 980px; margin: 0 auto; position: relative;">
                <div style="width: 645px; border-right: 1px solid #E5E5E5;">
                    <div class="filter-condition">
                        <label style="font-size: 14px;">
                            标的类型</label>
                        <ul class="filter-content" id="safeclass">
                            <li class="filter-item @(ViewBag.safeclass == 0 ? "active" : "")" value="0">不限</li>
                            <li class="filter-item @(ViewBag.safeclass == 3 ? "active" : "")" value="3">
                                担保标</li>
                            <li class="filter-item @(ViewBag.safeclass == 2 ? "active" : "")" value="2">
                                抵押标</li>
                        </ul>
                    </div>
                    <div class="filter-condition">
                        <label style="font-size: 14px;">
                            借款期限</label>
                        <ul class="filter-content" id="deadline">
                            <li class="filter-item @(ViewBag.deadline == 0 ? "active" : "")" value="0">不限</li>
                            <li class="filter-item @(ViewBag.deadline == 1 ? "active" : "")" value="1">1-3月标</li>
                            <li class="filter-item @(ViewBag.deadline == 4 ? "active" : "")" value="4">4-5月标</li>
                            <li class="filter-item @(ViewBag.deadline == 6 ? "active" : "")" value="6">6-12月标</li>
                        </ul>
                    </div>
                    <div class="filter-condition">
                        <label style="font-size: 14px;">
                            还款状态</label>
                        <ul class="filter-content" id="status">
                            <li class="filter-item @(ViewBag.status == 0 ? "active" : "")" value="0">不限</li>
                            <li class="filter-item @(ViewBag.status == 1 ? "active" : "")" value="1">转让中</li>
                            <li class="filter-item @(ViewBag.status == 2 ? "active" : "")" value="2">转让完成</li>
                        </ul>
                    </div>
                </div>
                <div class="filter-condition" style="width: 200px; position: absolute; top: 15px;right: 180px;">
@*                    <ul class="filter-content" style="line-height: 22px;">*@
@*                        <h3>新手疑问</h3>*@
@*                        <a href="#"><li>不限</li>*@
@*                        </a> <a href="#"><li>担保标</li>*@
@*                        </a> <a href="#"><li>抵押标</li></a>*@
@*                    </ul>*@
                </div>
            </div>
        </div>
    </div>
    <div style="background: #f8f8f8;padding-top: 40px;">
        <div class="ui-inner">
       <div class="ui-assign-tb">
        <table>
        <tr style="border: none;">
            <th style="width: 250px;">
                转让项目
            </th>
@*            <th>*@
@*                安全保障*@
@*            </th>*@
            <th>
                预期年化收益率
            </th>
            <th>
                剩余时间
            </th>
            <th>
                转让价格
            </th>
            <th>
                转让进度
            </th>
            <th style="width: 120px;">
            </th>
        </tr>
        @foreach (Assignment assign in Model)
        {
            Project project = Html.F().GetProject(assign.ProjectId);
            var agency = Html.F().GetAgency(project.Parent.AgencyId);
            <tr style="" class="assigns_tr_hover2">
                <td style="text-align: left; padding-left: 28px;">
                    @if (project.TypeID == 2)
                    {
                        <span class="ui-badge ui-badge-orange" title="资产抵押">押</span>
                    }
                    @if (project.TypeID == 3 || project.TypeID == 9 || project.TypeID == 10)
                    {
                        <span class="ui-badge ui-badge-green" title="机构担保">保</span>
                    }
                    <a href="@Url.Action("Index", "Assignment", new { id = assign.ID })">@project.Name</a>
                </td>
@*                <td>*@
@*                    @(agency == null ? "资产抵押" : agency.SubName)*@
@*                </td>*@
                <td>
                    12%
                </td>
                <td>
                    @if (assign.NeedMoney == 0)
                    {
                        <span>已卖出</span>
                    }
                    else
                    {
                        <span>@((project.RepayEndTime.Value.Date - DateTime.Now.Date).Days)天</span>
                    }
                </td>
                <td>@assign.Money.ToMoney()
                </td>
                <td style="width: 100px;">
                    <!--<div style="width: 120px; border: 1px solid #F8B3D0; height: 12px; margin-left: 50px;">
                            <em style="width: @(project.Progress.ToString("0.0") + '%'); display: block; background: #ffa010; height: 100%;                                                                                                                                                                                                                                                                                                                                                                                                                                                                    text-align: center;line-height: 40px;">@(project.Progress.ToString("0.0") + '%')</em>
                        </div>-->
                    <div id="@("assigns_" + i)" style="height: 60px;width: 100px;margin-left: 10px;">
                    </div>
                </td>
                <td>
                    @if (assign.Status == AssignmentStatus.Cancel)
                    {
                        <a href="javascript:;" class="ui-button ui-button-disable assgin-tb">已结束</a>
                    }
                    @if (assign.Status == AssignmentStatus.Completed)
                    {
                        <a href="javascript:;" class="ui-button ui-button-disable assgin-tb">已卖出</a>
                    }
                    @if (assign.Status == AssignmentStatus.Progress)
                    {
                        if (assign.EndTime <= DateTime.Now)
                        {
                        <a href="javascript:;" class="ui-button ui-button-disable assgin-tb">已结束</a>
                        }
                        else
                        {
                        <a href="@Url.Action("Index", "Assignment", new { id = assign.ID })" class="ui-button ui-button-orange assgin-tb">
                            购买</a>
                        }
                    }
                </td>
            </tr>
            
            <script type="text/javascript">
                $("#@("assigns_" + i)").ready(function() {
                    var@("assigns_" + i) = new JustGage({
                        id: "@("assigns_" + i)",
                        value: @assign.Progress.ToString("0.0"),
                        title:" ",
                        showMinMax:false,           
                        label: "",
                        showInnerShadow: false,
                        levelColors: [
                            "#2ecc71",
                            "#f1c40f",
                            "#e74c3c"
                        ],
                        gaugeWidthScale: 0.5
                    });
                });
            </script>
            
                  i++;
        }
    </table>
    <div style="width: 980px;padding: 25px 0;">
                @Html.ClientPager(Model)
            </div>
</div>
        </div>
    </div>
</div>

<script type="text/javascript">
    $().ready(function () {
        $("#assignmentlist a").siblings().removeClass('a_class').end().addClass('a_class');
        $("#assignmentlist div").siblings("div").css("display", "none").end().css("display", "block");
    });
    $('.filter-item').click(function () {
        $(this).siblings().removeClass('active').end().addClass('active');

        $.ajaxSetup({
            async: false
        });
        var safeclass = $("#safeclass li").filter(".active").val();
        var deadline = $("#deadline li").filter(".active").val();
        var status = $("#status li").filter(".active").val();
        var url = "/Home/AssignmentList?" + "safeclass=" + safeclass + "&deadline=" + deadline + "&status=" + status;
        window.location.href = url;

    });
</script>